var LEAUI_MIND={};tinymce.PluginManager.add("leaui_mind",function(a,b){function c(){function b(){var b=a.settings.language,c="//leanote.com/public/libs/mind/edit.html",d='<iframe id="leauiIfr" src="'+c+"?"+(new Date).getTime()+"&lang="+b+'" frameborder="0"></iframe>';return d}var c=a.dom,d=a.selection.getContent(),e=/<img.*?\/>/g,f=d.match(e),g=document.createElement("p");LEAUI_MIND={};for(var h in f){g.innerHTML=f[h];var i=g.firstChild;if(i&&"IMG"==i.nodeName){LEAUI_MIND.json=c.getAttrib(i,"data-mind-json");break}}var j=$(document).width()-10,k=$(document).height()-100;win=a.windowManager.open({title:"Mind Map",width:j,height:k,html:b(),buttons:[{text:"Cancel",onclick:function(){this.parent().parent().close()}},{text:"Insert Mind Map",subtype:"primary",onclick:function(b){var c=this,d=document.getElementById("leauiIfr").contentWindow,e=d.km;return void e.exportData("png").then(function(b){var d=JSON.stringify(e.exportJson()),f='<img src="'+b+'" data-mce-src="-" data-mind-json=\''+d+"'>";a.insertContent(f),c.parent().parent().close()})}}]})}a.addButton("leaui_mind",{icon:"mind",tooltip:"Insert/edit mind map",onclick:c,stateSelector:"img[data-mind-json]"})});